<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <style>
      * {
        box-sizing: border-box;
      }
      #app {
        margin: 100px 0 0 50px;
      }
      #app span {
        font-size: 16px;
        font-style: normal;
      }
      input {
        height: 30px;
        width: 150px;
      }
      select {
        height: 30px;
        width: 150px;
        margin-bottom: 10px;
      }
    </style>
    <div id="app">
      <h1>
        {{biaoti1}}<span>{{pindao1}}</span>
        <button @click="change">编辑</button>
      </h1>
      <div v-show="flag">
        标题：<input type="text" v-model="msg" /><br /><br />
        频道：<select v-model="pindao">
          <option>请选择频道</option>
          <option>前端</option>
          <option>运维</option>
          <option>测试</option>
        </select>
        <br />
        <button @click="cancel">取消</button>
        <button @click="sure">确认</button>
      </div>
    </div>
    <script src="./vue.js"></script>
    <script>
      const app = new Vue({
        el: "#app",
        data: {
          biaoti1: "如何学好前端",
          pindao1: "运维",
          msg: "",
          flag: false,
          pindao: "",
        },
        methods: {
          change() {
            this.flag = true
          },
          sure() {
            if (this.msg.trim() !== "") {
              this.biaoti1 = this.msg
              this.pindao1 = this.pindao
              this.flag = false
            } else {
              alert("不能为空")
            }
          },
          cancel() {
            this.flag = false
          },
        },
      })
      log
    </script>
  </body>
</html>